{- «•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»

    Copyright © 2011 - 2021, Ingo Wechsung
    All rights reserved.
    
    Redistribution and use in source and binary forms, with or
    without modification, are permitted provided that the following
    conditions are met:
    
        Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
    
        Redistributions in binary form must reproduce the above
        copyright notice, this list of conditions and the following
        disclaimer in the documentation and/or other materials provided
        with the distribution. Neither the name of the copyright holder
        nor the names of its contributors may be used to endorse or
        promote products derived from this software without specific
        prior written permission. 
        
    THIS SOFTWARE IS PROVIDED BY THE
    COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
    AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    THE POSSIBILITY OF SUCH DAMAGE.

    «•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•» -}

{--
 * Definitions for native components found in packages @java.awt@, @java.awt.event@
 -}
 
package frege.java.Awt where

-- import frege.j.Util

   

--- a bare @java.awt.Component@
data Component = native java.awt.Component where
    native setEnabled :: MutableIO Component -> Bool -> IO () 
    native setVisible :: MutableIO Component -> Bool -> IO ()
   


--- a bare @java.awt.Container@
data Container = native java.awt.Container where
    native add          :: MutableIO Container -> MutableIO Component -> IOMutable Component
    native setLayout    :: MutableIO Container -> MutableIO LayoutManager -> IO ()


data LayoutManager = native java.awt.LayoutManager 

--- some @java.awt.Window@
data Window = native java.awt.Window where
        native pack :: MutableIO Window -> IO ()


-- ------------------ AWTEvent ----------------------------


--- an object with compile time type @java.awt.AWTEvent@
data AWTEvent = native java.awt.AWTEvent


-- ----------------------- ActionEvent ------------------------


--- an object with compile time type @java.awt.event.ActionEvent@
data ActionEvent = native java.awt.event.ActionEvent where
    pure native alt_mask   java.awt.event.ActionEvent.ALT_MASK   :: Int
    pure native ctrl_mask  java.awt.event.ActionEvent.CTRL_MASK  :: Int
    pure native meta_mask  java.awt.event.ActionEvent.META_MASK  :: Int
    pure native shift_mask java.awt.event.ActionEvent.SHIFT_MASK :: Int
    native getActionCommand :: MutableIO ActionEvent -> IO String
    native getModifiers     :: MutableIO ActionEvent -> IO Int


-- ---------------- ActionListener ----------------------
native module where {
    /** <p> create an ActionListener from a ActionEventT s -&gt; ST s () function </p> */
    public static   
        java.awt.event.ActionListener actionListener(
                final Func.U<java.awt.event.ActionEvent, Func.U<RealWorld, Short>> arg1) {
            return new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    PreludeBase.TST.performUnsafe(arg1.apply(Thunk.lazy(e)).call()).call();
                }
            };
    }
}

--- an object with compile time type @java.awt.event.ActionListener@
data ActionListener = native java.awt.event.ActionListener where
    native actionPerformed :: MutableIO ActionListener -> MutableIO ActionEvent -> IO ()
    --- make an action listener from a function
    native new Awt.actionListener 
                           :: (MutableIO ActionEvent -> IO ()) -> IOMutable ActionListener

-- ------------------- Frame --------------------------------
data Frame = native java.awt.Frame where
    native setTitle :: MutableIO Frame -> String -> IO ()    
